package br.com.playonline.persistencia;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import br.com.playonline.domain.CarrinhoBolao;

@Component
public class CarrinhoBolaoHibernateDAO extends HibernateDAOGenerico<CarrinhoBolao, Long> {

	@Autowired
	public CarrinhoBolaoHibernateDAO(SessionFactory sessionFactory) {
		super(sessionFactory);
	}

	public List<CarrinhoBolao> findByCarrinho(Long idCarrinho){
		return findByCriteria(Expression.eq("carrinho.id", idCarrinho));
	}
	
	public List<CarrinhoBolao> findByCarrinhoAndBolao(Long idBolao, Long idCarrinho){
		return findByCriteria(Restrictions.and(Expression.eq("bolao.id", idBolao),Expression.eq("carrinho.id", idCarrinho)));
	}

}
